package database;

import classes.Ability;

public class DBAbility {
	
	private static DBAbility instance;
	private Ability[] abilities;
	
	private DBAbility(){
		this.abilities = new Ability[122];
		this.abilities[0] = new Ability("Adaptability", "Type matchup effects are boosted for moves of the same type as the user");
		this.abilities[1] = new Ability("Aftermath", "If user is knocked out by a direct attack, foe takes damage equal to 1/4 of user's max HP");
		this.abilities[2] = new Ability("Air Lock", "All Pokémon in battle are immune to weather effects");
		this.abilities[3] = new Ability("Anger Point", "Maximizes user's Attack when user is hit by an attack");
		this.abilities[4] = new Ability("Anticipation", "Senses the foe's dangerous moves");
		this.abilities[5] = new Ability("Arena Trap", "Prevents foe from fleeing or switching out (no effect against Flying-type Pokémon or Pókemon with the Levitate Ability)");
		this.abilities[6] = new Ability("Bad Dreams", "Reduces a sleeping foe's HP");
		this.abilities[7] = new Ability("Battle Armor", "Foe cannot score a critical hit");
		this.abilities[8] = new Ability("Blaze", "Raises the power of Fire-type moves by 50% when users HP drops below 1/3");
		this.abilities[9] = new Ability("Chlorophyll", "Speed is doubled in Sunny weather");
		this.abilities[10] = new Ability("Clear Body", "Protects against moves and Abilities that lower stats");
		this.abilities[11] = new Ability("Cloud Nine", "All Pokémon in battle are immune to weather effects");
		this.abilities[12] = new Ability("Color Change", "Changes the Pokémon's type to the foe's move");
		this.abilities[13] = new Ability("Compound Eyes", "Raises accuracy by 30%");
		this.abilities[14] = new Ability("Cute Charm", "30% chance of inflicting Infatuation on a foe who hits user with a direct attack");
		this.abilities[15] = new Ability("Damp", "Prevents combatants from self destructing");
		this.abilities[16] = new Ability("Download", "Adjusts power according to the foe's ability");
		this.abilities[17] = new Ability("Drizzle", "Turns weather to Rain when user enters battle");
		this.abilities[18] = new Ability("Drought", "Turns weather to the Sunny condition when user enters battle");
		this.abilities[19] = new Ability("Dry Skin", "Restores HP when user is hit by a Water-type move (in the Rain weather condition, it regenerates HP each turn)");
		this.abilities[20] = new Ability("Early Bird", "The Pokémon awakens quickly from sleep");
		this.abilities[21] = new Ability("Effect Spore", "30% chance of counter-inflict Poison, Paralysis, or Sleep on a foe who hits user with direct attack");
		this.abilities[22] = new Ability("Filter", "Minimizes the damage taken from super effective moves");
		this.abilities[23] = new Ability("Flame Body", "30% chance of inflicting the Burned condition on a foe who hits user with a direct attack");
		this.abilities[24] = new Ability("Flash Fire", "When user is hit by Fire-type move, it takes no damage and the power of its Fire-type moves increases by 50%");
		this.abilities[25] = new Ability("Flower Gift", "In the Sunny weather condition, user's and ally's Attack and Sp. Defense increase by 50%");
		this.abilities[26] = new Ability("Forecast", "Changes Castform's appearance and type according to the weather");
		this.abilities[27] = new Ability("Forewarn", "Determines what moves the foe has");
		this.abilities[28] = new Ability("Frisk", "The Pokémon can check the foe's held item");
		this.abilities[29] = new Ability("Gluttony", "Encourages the early use of a held Berry");
		this.abilities[30] = new Ability("Guts", "Attack stat rises by 50% when user has a status condition");
		this.abilities[31] = new Ability("Heatproof", "Halves damage taken from Fire-type moves and the Burn status condition");
		this.abilities[32] = new Ability("Honey Gather", "The Pokémon gather Honey from somewhere");
		this.abilities[33] = new Ability("Huge Power", "Gives user high Attack stat (if Huge Power is negated, attack is halved)");
		this.abilities[34] = new Ability("Hustle", "Raises Attack by 50%, but lowers the accuracy of user's physical moves by 20%");
		this.abilities[35] = new Ability("Hydration", "In the Rain weather condition, user's status conditions are cured at the end of the turn");
		this.abilities[36] = new Ability("Hyper Cutter", "Attack cannot be lowered");
		this.abilities[37] = new Ability("Ice Body", "Gradually restores HP in the Rain weather condition");
		this.abilities[38] = new Ability("Illuminate", "Raises the likelyhood of meeting wild Pokémon");
		this.abilities[39] = new Ability("Immunity", "Prevents the Pokémon from getting poisoned");
		this.abilities[40] = new Ability("Inner Focus", "The Pokémon is protected from flinching");
		this.abilities[41] = new Ability("Insomnia", "Prevents the Pokémon from falling asleep");
		this.abilities[42] = new Ability("Intimidate", "Lowers foe's Attack by 1 when user enters battle");
		this.abilities[43] = new Ability("Iron Fist", "Increases the power of punching moves like Mach Punch, Bullet Punch, etc.");
		this.abilities[44] = new Ability("Keen Eye", "Prevents the Pokémon from losing accuracy");
		this.abilities[45] = new Ability("Klutz", "The Pokémon can't use any held items");
		this.abilities[46] = new Ability("Leaf Guard", "Prevents status problems in Sunny weather");
		this.abilities[47] = new Ability("Levitate", "User is immune to Ground-type moves");
		this.abilities[48] = new Ability("Lightningrod", "The Pokémon draws in all Electric-type moves");
		this.abilities[49] = new Ability("Limber", "Prevents the Pokémon from paralysis");
		this.abilities[50] = new Ability("Liquid Ooze", "When foe uses a move to drain user's HP, the foe takes damage instead.");
		this.abilities[51] = new Ability("Magic Guard", "Protects user from damage that isn't direct damage from an attack (e.g. damage from the Poison condition or Spikes)");
		this.abilities[52] = new Ability("Magma Armor", "Prevents the Pokémon from becoming frozen");
		this.abilities[53] = new Ability("Magnet Pull", "Prevents Steel-type Pokémon from fleeing or switching out");
		this.abilities[54] = new Ability("Marvel Scale", "When user has a status condition, its Defense increases 50%");
		this.abilities[55] = new Ability("Minus", "Raises Sp. Defense by 50% if a Pókemon with the Plus Ability is in battle");
		this.abilities[56] = new Ability("Mold Breaker", "User can attack without being affected by foe's Ability");
		this.abilities[57] = new Ability("Motor Drive", "When user is hit by an Electric-type move, it takes no damage and its Speed goes up by 1");
		this.abilities[58] = new Ability("Multitype", "Changes type to match the held Plate.");
		this.abilities[59] = new Ability("Natural Cure", "Cure user's status conditions when user switches out of battle");
		this.abilities[60] = new Ability("No Guard", "Both sides' moves always strikes their target");
		this.abilities[61] = new Ability("Normalize", "All the Pokémon's moves become the Normal-type");
		this.abilities[62] = new Ability("Oblivious", "Prevents the Pokémon from becoming infatuated");	
		this.abilities[63] = new Ability("Overgrow", "Raises the power of Grass-type moves by 50% when the user's HP drops below 1/3");
		this.abilities[64] = new Ability("Own Tempo", "Prevents the Pokémon from becoming confused");
		this.abilities[65] = new Ability("Pickup", "The pokémon may pick up items");
		this.abilities[66] = new Ability("Plus", "Raises Sp. Attack by 50% if a Pókemon with the Minus Ability is in battle");
		this.abilities[67] = new Ability("Poison Heal", "When user has the Poison condition, it recovers some HP each turn");
		this.abilities[68] = new Ability("Poison Point", "30% chance of inflicting Poison on a foe who hits user with a direct attack");
		this.abilities[69] = new Ability("Pressure", "When user is hit by a foe's move, that move loses 1 extra PP");
		this.abilities[70] = new Ability("Pure Power", "Gives user high Attack stat (if Pure Power is negated, Attack is halved)");
		this.abilities[71] = new Ability("Quick Feet", "When user has a status condition, its Speed increases 50%");
		this.abilities[72] = new Ability("Rain Dish", "The Pokémon gradually recovers HP in rain");
		this.abilities[73] = new Ability("Reckless", "Raises the power of moves with recoil damage, such as Junp Kick and Hi Jump Kick");
		this.abilities[74] = new Ability("Rivalry", "Raises attack if the foe is of the same gender");
		this.abilities[75] = new Ability("Rock Head", "No recoil damage from moves like Take Down and Double-Edge");
		this.abilities[76] = new Ability("Rough Skin", "Does some damage to foes taht land a direct attack");
		this.abilities[77] = new Ability("Run Away", "Enables sure getaway from wild Pokémon");		
		this.abilities[78] = new Ability("Sand Stream", "Turns weather condition to Sandstorm when user enters battle");
		this.abilities[79] = new Ability("Sand Veil", "Evasion increases in the Sandstorm weather condition");
		this.abilities[80] = new Ability("Scrappy", "User can hit Ghost-type Pokémon without Normal- and Fight-type moves");
		this.abilities[81] = new Ability("Serene Grace", "Doubles moves' chances of inflicting side effects");
		this.abilities[82] = new Ability("Shadow Tag", "Prevents foe from fleeing or switching out (no effect if both sides have Shadow Tag)");
		this.abilities[83] = new Ability("Shell Armor", "Foe cannot score a critical hit");
		this.abilities[84] = new Ability("Shield Dust", "Blocks the added effects of attacks taken");
		this.abilities[85] = new Ability("Simple", "The Pokémon is prone to wild stat changes");		
		this.abilities[86] = new Ability("Skill Link", "Moves that make multiple attacks per turn will strike the maximum number of times");
		this.abilities[87] = new Ability("Slow Start", "Temporarily halves Attack and Speed");
		this.abilities[88] = new Ability("Sniper", "Critical hits d more damage");
		this.abilities[89] = new Ability("Snow Cloak", "Evasion increases in the Hail weather condition");
		this.abilities[90] = new Ability("Snow Warning", "Turns weather condition to Hail when user enters battle");
		this.abilities[91] = new Ability("Solar Power", "In the Sunny weather condition, Attack increases by 50% but HP drops each turn");
		this.abilities[92] = new Ability("Solid Rock", "Minimizes the damage taken from super effective moves");
		this.abilities[93] = new Ability("Soundproof", "Protects user from sound-based moves");
		this.abilities[94] = new Ability("Speed Boost", "Each turn, Speed goes up by 1");
		this.abilities[95] = new Ability("Stall", "The Pokémon moves after even slower foes");		
		this.abilities[96] = new Ability("Static", "30% chance of inflicting Paralysis on a foe who hits user with a direct attack");
		this.abilities[97] = new Ability("Steadfast", "User's Speed goes up by 1 every time the foe flinches");
		this.abilities[98] = new Ability("Stench", "The stench helps keep wild Pokémon away");
		this.abilities[99] = new Ability("Sticky Hold", "Protects the Pokémon from item theft");
		this.abilities[100] = new Ability("Storm Drain", "The Pokémon draws in all Water-type moves");
		this.abilities[101] = new Ability("Sturdy", "Protects user against one-hit KO moves like Horn Drill and Sheer Cold");
		this.abilities[102] = new Ability("Suction Cups", "Negates moves taht normally force the foe to switch out, such as Whirlwind and Roar");
		this.abilities[103] = new Ability("Super Luck", "Raises user's critical-hit rate");
		this.abilities[104] = new Ability("Swarm", "Raises the power of Bug-type moves by 50% when user's HP drops  below 1/3");
		this.abilities[105] = new Ability("Swift Swim", "Speed is doubled in the Rain weather condition");
		this.abilities[106] = new Ability("Synchronize", "When user has the Poison, Paralysis, or Burned condition, foe receives the same condition");
		this.abilities[107] = new Ability("Tangled Feet", "Raises evasion if the Pokémon is confused");
		this.abilities[108] = new Ability("Technician", "Moves with Power of 60 or less have their power increased by 50%");
		this.abilities[109] = new Ability("Thick Fat", "Halves damage taken from Fire- and Ice-type moves");		
		this.abilities[110] = new Ability("Tinted Lens", "Negates the type disadvantage of user's moves that are not very effective");
		this.abilities[111] = new Ability("Torrent", "Strengthens Water-type moves by 50% when user's HP drop below 1/3");
		this.abilities[112] = new Ability("Trace", "The Pokémon copies the foe's ability");
		this.abilities[113] = new Ability("Truant", "The Pokémon can't attack on consecutive turns");
		this.abilities[114] = new Ability("Unaware", "Ignores any chance in ability by the foe");
		this.abilities[115] = new Ability("Unburden", "User's Speed doubles if it loses its held item (Speed returns to normal if users picks up another item)");
		this.abilities[116] = new Ability("Vital Spirit", "Prevents the Pokémon from falling asleep");
		this.abilities[117] = new Ability("Volt Absorb", "When user is hit by an Electric-type move, it gains HP rather than taking damage");
		this.abilities[118] = new Ability("Water Absorb", "Restores HP if hit by a Water-type move");
		this.abilities[119] = new Ability("Water Veil", "Prevents the Pokémon from getting a burn");
		this.abilities[120] = new Ability("White Smoke", "Protects against moves and Abilities that lower stats");
		this.abilities[121] = new Ability("Wonder Guard", "Protects user against all moves except super effective ones");		
	}
	
	public Ability getAbility(String ability){
		if (this.abilities.length <= 0) return null;

		int start = 0;
		int end = this.abilities.length - 1;
		int middle = (end + start) / 2;
		
		int comparison = 0;
		while (start <= end){
			comparison = ability.compareToIgnoreCase(this.abilities[middle].getName());
			
			if (comparison == 0){
				return this.abilities[middle];
			}
			
			if (comparison > 0){
				start = middle + 1;
			}
			
			if (comparison < 0){
				end = middle - 1;
			}
		
			middle = (end + start) / 2;	
		}
		return null;
	}	
		
	public static void createInstance(){
		if (instance != null) return;
		
		instance = new DBAbility();
	}
	
	public static DBAbility getInstance(){
		return instance;
	}
}
